package com.zysdev.avtask2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button

class MainActivity : AppCompatActivity() {

    private val btnStart: Button by lazy {
        findViewById(R.id.btn_start)
    }
//    private val btnPause: Button by lazy {
//        findViewById(R.id.btn_pause)
//    }
//    private val btnResume: Button by lazy {
//        findViewById(R.id.btn_resume)
//    }
    private val btnStop: Button by lazy {
        findViewById(R.id.btn_stop)
    }
    private var recordManager: RecordManager? = null;

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        recordManager = RecordManager(this)

        btnStart.setOnClickListener {
//            val s = filesDir?.path ?: ""
//            Log.e("---", "s=$s")
            recordManager?.start()
        }

        btnStop.setOnClickListener {
            //录制的pcm文件缺少头信息，不能播放，需要转换为wav格式
            recordManager?.stop()
        }
    }

}